package pld.car.service.impl;

import java.util.List;

import pld.car.bean.CustMsg;
import pld.car.bean.News;
import pld.car.service.*;

public class CustMsgServiceImpl extends BaseServiceImpl implements CustMsgService {

	public CustMsgServiceImpl() {
		System.out.println("CustMsgServiceImpl init!");
	}

	// 根据id删除指定的新闻
	public void delete(int id) {
		this.getCustMsgDao().delete(id);
	}

	// 保存新闻
	public void insert(CustMsg o) {
		this.getCustMsgDao().insert(o);
	}

	// 获取custMsg表的记录数
	public int getMsgCount() {
		long count;
		String sql = "select count(*) from CustMsg";
		List<Object> ob = this.getCustMsgDao().runSQL(sql);
		count = (Long) ob.get(0);
		return (int) count;
	}

	// 获取指定起始记录和数量的数据
	public List<Object> getMsgTitle(int first, int number) {
		String sql = "select custMsgID, title, name, mobile, createDate from CustMsg order by id desc";
		return this.getCustMsgDao().runSQL(sql, first, number);
	}

	// 根据id查询到指定的留言
	public CustMsg findMsgByID(int id) {
		return this.getCustMsgDao().findMsgByID(id);
	}
}
